//
// Created by redcat1 on 12.05.2024.
//

#include "figures.h"
#include <cmath>

//
Rectangle::Rectangle(double length_, double width_)
  : Figure()
  , length(length_)
  , width(width_)
{}

//
double Rectangle::Area() const
{
  return length * width;
}

//
double Rectangle::Perimeter() const
{
  return 2. * (length + width);
}

//
Circle::Circle(double radius_)
  : Figure()
  , radius(radius_)
{}

//
double Circle::Area() const
{
  return M_PI * radius * radius;
}

//
double Circle::Perimeter() const
{
  return 2. * M_PI * radius;
}

//
RightTriangle::RightTriangle( double leg1_, double leg2_ )
  : Figure()
  , leg1(leg1_)
  , leg2(leg2_)
{}

//
double RightTriangle::Area() const
{
  return leg1 * leg2 / 2.;
}

//
double RightTriangle::Perimeter() const
{
  return leg1 + leg2 + std::hypot(leg1, leg2);
}
